#pragma once
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
#include <random>
#include <algorithm>
#include <chrono>
#include "Graph.h"
#include "PlanarGraphGenerator.h"

using namespace std;

void Pro1() {
	ifstream pro1("data/problem1.txt");
	if (!pro1.is_open()) {
		cout << "Unable to open file problem1.txt" << endl;
	}
	Graph g(4);
	g.ReadData(pro1);
	auto start = chrono::high_resolution_clock::now();
	g.Coloring(1, 0, g.Find_MRV_DH());
	auto end = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::microseconds>(end - start);
	cout << "Problem1:>" << endl;
	cout << "Solutions: " << g.GetSolutions() << endl;
	cout << "Time taken: " << duration.count() << " microseconds" << endl << endl;
}
void Pro2_1() {
	ifstream data1("data/le450_5a.col");
	if (!data1.is_open()) {
		cout << "Unable to open file le450_5a.col" << endl;
	}
	Graph g(5);
	g.ReadData(data1);
	auto start = chrono::high_resolution_clock::now();
	g.Coloring(1, 0, g.Find_MRV_DH());
	auto end = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(end - start);
	cout << "Problem2_1:>" << endl;
	cout << "Solutions: " << g.GetSolutions() << " * 5!" << endl;
	cout << "Time taken: " << duration.count() << " ms" << endl << endl;
}
void Pro2_2() {
	ifstream data2("data/le450_15b.col");
	if (!data2.is_open()) {
		cout << "Unable to open file le450_15b.col" << endl;
	}
	Graph g(15);
	g.ReadData(data2);
	auto start = chrono::high_resolution_clock::now();
	g.Coloring(1, 0, 1);
	auto end = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(end - start);
	cout << "Problem2_2:>" << endl;
	cout << "Solutions: " << g.GetSolutions() << " * 15!" << endl;
	cout << "Time taken: " << duration.count() << " ms" << endl << endl;
}
void Pro2_3() {
	ifstream data3("data/le450_25a.col");
	if (!data3.is_open()) {
		cout << "Unable to open file le450_25a.col" << endl;
	}
	Graph g(25);
	g.ReadData(data3);
	auto start = chrono::high_resolution_clock::now();
	g.Coloring(1, 0, g.Find_MRV_DH());
	auto end = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(end - start);
	cout << "Problem2_3:>" << endl;
	cout << "Solutions: " << g.GetSolutions() << " * 25!" << endl;
	cout << "Time taken: " << duration.count() << " ms" << endl << endl;
}
void Pro_3(string& filename) {
	ifstream data(filename);
	if (!data.is_open()) {
		cout << "Unable to open file " << filename << endl;
	}
	Graph g(4);
	g.ReadData(data);
	auto start = chrono::high_resolution_clock::now();
	g.Coloring(1, 0, g.Find_MRV_DH());
	auto end = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(end - start);
	cout << "Problem3:>" << endl;
	cout << "Solutions: " << g.GetSolutions() << " * 4!" << endl;
	cout << "Time taken: " << duration.count() << " ms" << endl << endl;
}


int main() {
	for (int i = 0; i < 5; i++) {
		//Pro1();
		//Pro2_1();
		//Pro2_2();
		//Pro2_3();
		string filename = "data/le30_" + to_string(i + 1) + "_4a.col";
		PlanarGraphGenerator generator;
		generator.generate(filename, 30);
		for (int j = 0; j < 5; j++) {
			Pro_3(filename);
		}
	}
	
	
	return 0;
}